package org.fireflow2.designer.eclipse.modelwrapper.basic;

import org.fireflow.model.data.Expression;
import org.fireflow.model.data.impl.ExpressionImpl;
import org.fireflow.pdl.fpdl20.diagram.DiagramElement;
import org.fireflow.pdl.fpdl20.diagram.Fpdl20DiagramElement;
import org.fireflow.pdl.fpdl20.process.Transition;
import org.fireflow2.designer.eclipse.modelwrapper.ConnectorWrapper;
import org.fireflow2.designer.eclipse.modelwrapper.SubProcessWrapper;

public class TransitionWrapper extends ConnectorWrapper {

	public TransitionWrapper(SubProcessWrapper subflowWrapper,Transition arg0,DiagramElement diagramElement) {
		super(subflowWrapper,arg0,diagramElement);
	}
	public  String getElementType(){
		return Fpdl20DiagramElement.TRANSITION.name();
	}	

	
	public void setCondition(String s) {
		Expression oldValue = ((Transition) this.getWorkflowModelElement()).getCondition();

		ExpressionImpl newValue = new ExpressionImpl();
		newValue.setBody(s);
		((Transition) this.getWorkflowModelElement()).setCondition(newValue);

		this.firePropertyChange(WF_ELEMENT_ATTR, oldValue, s);
	}

	public String getCondition() {
		Expression oldValue = ((Transition) this.getWorkflowModelElement()).getCondition();
		if (oldValue!=null){
			return oldValue.getBody();
		}
		return null;
	}
}
